package com.ruoyi.security.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.security.mapper.SecurityDutyMapper;
import com.ruoyi.security.domain.SecurityDuty;
import com.ruoyi.security.service.ISecurityDutyService;

/**
 * 保安值班Service业务层处理
 *
 * @author cjie
 * @date 2022-04-27
 */
@Service
public class SecurityDutyServiceImpl implements ISecurityDutyService {
    @Autowired
    private SecurityDutyMapper securityDutyMapper;

    /**
     * 查询保安值班
     *
     * @param id 保安值班ID
     * @return 保安值班
     */
    @Override
    public SecurityDuty selectSecurityDutyById(Long id) {
        return securityDutyMapper.selectSecurityDutyById(id);
    }

    /**
     * 查询保安值班列表
     *
     * @param securityDuty 保安值班
     * @return 保安值班
     */
    @Override
    public List<SecurityDuty> selectSecurityDutyList(SecurityDuty securityDuty) {
        return securityDutyMapper.selectSecurityDutyList(securityDuty);
    }

    /**
     * 新增保安值班
     *
     * @param securityDuty 保安值班
     * @return 结果
     */
    @Override
    public int insertSecurityDuty(SecurityDuty securityDuty) {
        securityDuty.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        securityDuty.setCreateTime(DateUtils.getNowDate());
        securityDuty.setCreateBy(SecurityUtils.getUsername());
        return securityDutyMapper.insertSecurityDuty(securityDuty);
    }

    /**
     * 修改保安值班
     *
     * @param securityDuty 保安值班
     * @return 结果
     */
    @Override
    public int updateSecurityDuty(SecurityDuty securityDuty) {
        securityDuty.setUpdateTime(DateUtils.getNowDate());
        securityDuty.setUpdateBy(SecurityUtils.getUsername());
        return securityDutyMapper.updateSecurityDuty(securityDuty);
    }

    /**
     * 批量删除保安值班
     *
     * @param ids 需要删除的保安值班ID
     * @return 结果
     */
    @Override
    public int deleteSecurityDutyByIds(Long[] ids) {
        return securityDutyMapper.deleteSecurityDutyByIds(ids);
    }

    /**
     * 删除保安值班信息
     *
     * @param id 保安值班ID
     * @return 结果
     */
    @Override
    public int deleteSecurityDutyById(Long id) {
        return securityDutyMapper.deleteSecurityDutyById(id);
    }
}
